package com.huangguolin.cloud.login.control;


import com.alibaba.fastjson.JSON;
import com.huangguolin.cloud.login.entity.MenuLevelEntity;
import com.huangguolin.cloud.login.service.LoginService;
import com.huangguolin.cloud.mybatis.entity.PtMenuEntity;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class MainController {

    @Resource
    HttpSession session = null;
    private Logger logger = LogManager.getLogger(this.getClass());
    @Resource
    private LoginService loginService = null;
    @RequestMapping("/")
    public String mainPage(){
        String lang = LocaleContextHolder.getLocale().toString();
        /**
         * 对网页图片进行切换
         */
        session.setAttribute("lang",lang);
        List<MenuLevelEntity> list = loginService.queryMenuList();
        session.setAttribute("menuList",list);
    return "login/mainPage";
    }

    @RequestMapping("/home")
    public String homePage(){
        return "login/homepage";
    }

//    @RequestMapping("queryMenuList")
//    @ResponseBody
//    public String queryMenuList(){
//        List<MenuLevelEntity> list = loginService.queryMenuList();
//
//        return JSON.toJSONString(list);
//    }

}
